exports.bargain_ranking_list = function(req,res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    var bc_most_price = 0

    var skip  =  restfulParams.skip == undefined  ? 0 : restfulParams.skip;
    var limit =  restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;


    //任务流创建
    async.waterfall([
  
           
        //获取荣誉榜前10
        function(cb){

            R.SEND_HTTP(
                req,
                {
                    url: CORE_APIConfig.coreAPI.searchBargainJoinUserInfo +  "/bj_oaid/" + restfulParams.oa_id + "/sort_order/bj_get_cut_price-desc/skip/"+skip+"/limit/" + limit,
                    method: 'GET',
                },
                function (err, data) {
                    //判断是否有错误信息
                    if (err) {
                        return cb(err, data);
                    }
                    
                    resultData.BargainJoinUserInfo = data.data;

                    cb();

                }
            );

        },
        //查询这个活动的最大价格
        function(cb){
            //console.log(123);
            R.SEND_HTTP(
                req,
                {
                    url: CORE_APIConfig.coreAPI.search_bargain_activity_config +  "/bc_oaid/" + restfulParams.oa_id,
                    method: 'POST',
                    data: {
                        fields: ["bc_most_price",].join(",")
                    }
                },
                function (err, data) {
                    //判断是否有错误信息
                    if (err) {
                        return cb(err, data);
                    }

                    bc_most_price = data.data[0].bc_most_price;

                    cb();

                }
            );

        },


        function(cb){

            var tasks = [];

            //循环节点列表
            resultData.BargainJoinUserInfo.forEach(function (item, i) {

                //创建每一个插入任务
                tasks.push(function (cb) {

                    item.now_price = parseFloat(parseFloat(item.bc_most_price) - parseFloat(item.bj_get_cut_price)).toFixed(2);
                    cb();

                });

            });

            async.waterfall(tasks, cb);


        },

        ],function(err, result){

            //返回最终拼接结果
            RES.response(res,true,resultData);

        }
    );

};